package com.wc.alorithm_luogu.P1789;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/22 11:52
 * @description https://www.luogu.com.cn/problem/P1789
 * 插火把(涂色问题)
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[][] map = new int[n][n];

        for (int[] row : map) {
            Arrays.fill(row, 1);
        }
        Main main = new Main();
        int i;
        int j;
        while (m-- > 0) {
            i = sc.nextInt();
            j = sc.nextInt();
            main.light(map, i - 1, j - 1);
        }
        while (k-- > 0) {
            i = sc.nextInt();
            j = sc.nextInt();
            main.stone(map, i - 1, j - 1);
        }
//        main.show(map);
        System.out.println(main.sum(map));
    }

    /**
     * 火把涂色
     *
     * @param map 地图
     * @param i   火把放置x轴
     * @param j   火把放置y轴
     */
    public void light(int[][] map, int i, int j) {
        // 计算出上下左右边界
        int left = i;
        int right = i;
        int up = j - 2;
        int down = Math.min(j + 2, map.length - 1);

        // 左边的截距
        int ld = -1;
        int rd = 1;

        // 上面超出边界
        while (up < 0) {
            if (up == j) {
                ld = -ld;
                rd = -rd;
            }
            left += ld;
            right += rd;
            up++;
        }

        for (int k = up; k <= down; k++) {
            int curLeft = left;
            int curRight = right;
            while (curLeft <= curRight) {
                curLeft = Math.max(curLeft, 0);
                curRight = Math.min(curRight, map.length - 1);
                map[k][curLeft] = 0;
                curLeft++;
            }
            if (k == j) {
                ld = -ld;
                rd = -rd;
            }
            left += ld;
            right += rd;
        }
    }

    /**
     * 萤石涂色
     *
     * @param map 地图
     * @param i   萤石放置x轴
     * @param j   萤石放置y轴
     */
    public void stone(int[][] map, int i, int j) {
        // 计算出上下左右边界
        int up = Math.max(i - 2, 0);
        int down = Math.min(i + 2, map.length - 1);
        int left = Math.max(j - 2, 0);
        int right = Math.min(j + 2, map.length - 1);
        for (int k = up; k <= down; k++) {
            for (int l = left; l <= right; l++) {
                map[k][l] = 0;
            }
        }
    }

    /**
     * 统计map中还有多少个1
     *
     * @param map
     * @return
     */
    public int sum(int[][] map) {
        int sum = 0;
        for (int[] row : map) {
            for (int num : row) {
                sum += num;
            }
        }
        return sum;
    }

    public void show(int[][] map) {
        for (int[] row : map) {
            for (int num : row) {
                System.out.printf("%2d", num);
            }
            System.out.println();
        }
    }
}
